package com.example.demo_job.mapper;


import com.example.demo_job.entity.Company;
import com.example.demo_job.entity.Position;
import com.example.demo_job.entity.Recruit;
import com.example.demo_job.entity.Seeker;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SeekerMapper {
    @Insert("INSERT INTO seeker(susername, sname, spassword, sedu,sgender,sphone,sinfo) VALUES (#{susername}, #{sname},#{spassword}, #{sedu}, #{sgender}, #{sphone}, #{sinfo})")
    int register(String susername, String sname, String spassword, int sedu, String sgender, String sphone, String sinfo);

    @Select("SELECT * FROM seeker WHERE susername = #{susername}")
    Seeker findByUsername(String susername);

    @Select("SELECT * FROM seeker WHERE susername=#{susername} and spassword=#{spassword}")
    Seeker login(String susername, String spassword);

    @Select("SELECT sid FROM seeker WHERE susername=#{susername}")
    int findid(String susername);

    @Select("SELECT COUNT(*) FROM seeker")
    int findNum();

    @Select("SELECT sinfo FROM seeker where susername = #{susername}")
    String findinfo(String susername);

    @Select("SELECT * FROM position where pname like #{pname}")
    List<Position> findPositionByPos(String pname);

    @Select("SELECT * FROM company where cid=#{cid}")
    Company findCompanyBycid(int cid);

    @Select("SELECT * FROM company where cname like #{cname}")
    List<Company> findCompanyBycname(String cname);

    @Select("SELECT * FROM position where cid=#{cid}")
    List<Position> findPositionBycid(int cid);

    @Update("update seeker set spassword=#{newPassword} where sid=#{sid}")
    void updatePassword(int sid, String newPassword);

    @Select("SELECT * FROM position where pid=#{pid}")
    Position findPositionBypid(int pid);

    @Select("SELECT * FROM recruit where sid=#{sid}")
    List<Recruit> findRecruitBysid(int sid);

    @Select("SELECT sid FROM seeker WHERE susername = #{susername}")
    int findSeekerSidBySusername(String susername);

    @Select("SELECT * FROM company ")
    List<Company> getCompanyList();

    @Select("Select * FROM position")
    List<Position> showPosition();

    @Select("SELECT * FROM seeker where sid=#{sid}")
    Seeker findSeekerBysid(int sid);
}
